﻿@model Bonobo.Git.Server.Models.UserDetailModel
@{
    ViewBag.Title = @Resources.Account_Detail_Title;
}
@if (Model == null)
{   
    @Html.Partial("~/Views/Shared/_ItemNotFound.cshtml") 
}
else
{  
    <h1>@Model.Username</h1>

    <div class="pure-form pure-form-aligned detail">
        <fieldset>
            <div class="pure-control-group">
                @Html.LabelFor(m => m.Username)
                <span>@Model.Username</span>
            </div>
            <div class="pure-control-group">
                @Html.LabelFor(m => m.Name)
                <span>@Model.Name</span>
            </div>
            <div class="pure-control-group">
                @Html.LabelFor(m => m.Surname)
                <span>@Model.Surname</span>
            </div>
            <div class="pure-control-group">
                @Html.LabelFor(m => m.Email)
                <span>@Model.Email</span>
            </div>
            <div class="pure-control-group">
                @Html.LabelFor(m => m.Roles)
                <span>
                    @for (int i = 0; i < Model.Roles.Length; i++)
                    {
                        @Model.Roles[i]if (i + 1 != Model.Roles.Length)
                                       {<text>, </text>}
                    }
                </span>
            </div>
        </fieldset>
        <div class="pure-controls">
            @if (User.IsInRole(Definitions.Roles.Administrator))
            {
                <a class="pure-button" href="@Url.Action("Index")"><i class="fa fa-long-arrow-left"></i> @Resources.Account_Detail_Back</a>
            }
            else
            {
                <a class="pure-button" href="@Url.Action("Index", "Repository")"><i class="fa fa-long-arrow-left"></i> @Resources.Repository_Back</a>
            }
            @if (User.IsInRole(Definitions.Roles.Administrator) && !Model.IsReadOnly)
            {
                <a class="pure-button" href="@Url.Action("Edit", new { id = Model.Id })"><i class="fa fa-pencil-square-o"></i> @Resources.Account_Detail_Edit</a>
                <a class="pure-button" href="@Url.Action("Delete", new { id = Model.Id })"><i class="fa fa-trash-o"></i> @Resources.Account_Detail_Delete</a>       
            }
        </div>
    </div>
}
